/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Inicio.java
 *
 * Created on 18/02/2011, 10:06:03 AM
 */

package puntoventa;

import java.util.Timer;
import java.util.TimerTask;

/**
 *
 * @author Lab
 */
public class Inicio extends javax.swing.JFrame {

    /** Creates new form Inicio */
    public Inicio() {
        initComponents();
        this.setLocationRelativeTo(this);

        int delay = 1;   // delay for 5 sec.
        int period = 1;  // repeat every sec.


        // Get rotation the local date and time .
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(
                new TimerTask() {

                    public void run() {

                        Date.setText(Main.ObtenerHora());
                        // Set the variable in Date JLabel
                    }
                }, delay, period);
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton2 = new javax.swing.JButton();
        MainTitle = new javax.swing.JLabel();
        IniVentasB = new javax.swing.JButton();
        AdminB = new javax.swing.JButton();
        POS = new javax.swing.JLabel();
        Date = new javax.swing.JLabel();

        jButton2.setText("jButton2");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        MainTitle.setFont(new java.awt.Font("Tahoma", 1, 24));
        MainTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        MainTitle.setText("Farmarcia la Unik");

        IniVentasB.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        IniVentasB.setText("Empleado");
        IniVentasB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                IniVentasBActionPerformed(evt);
            }
        });

        AdminB.setFont(new java.awt.Font("Tahoma", 0, 18));
        AdminB.setText("Administrador");
        AdminB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AdminBActionPerformed(evt);
            }
        });

        POS.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        POS.setText("Punto de Venta");

        Date.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Date.setText("YYYY/MM/DD HH:MM:SS");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(POS, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(IniVentasB, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)
                .addComponent(AdminB, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(MainTitle, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE)
            .addComponent(Date, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(MainTitle)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Date)
                .addGap(13, 13, 13)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(AdminB, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(IniVentasB, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(POS)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void AdminBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AdminBActionPerformed
        Intro_admin in = new Intro_admin();
        in.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_AdminBActionPerformed

    private void IniVentasBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IniVentasBActionPerformed
        Intro_user inu = new Intro_user();
        inu.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_IniVentasBActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Inicio().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AdminB;
    private javax.swing.JLabel Date;
    private javax.swing.JButton IniVentasB;
    private javax.swing.JLabel MainTitle;
    private javax.swing.JLabel POS;
    private javax.swing.JButton jButton2;
    // End of variables declaration//GEN-END:variables

}
